<?

class graphDeviceTraffic extends graphBase {
	protected function getOptions() {
		if (empty($this->device->inferfaces)) { $this->device->os->getResources();}
		$opts = array();
		$inoctets = array();
		$outoctets = array();
		$pluses = array();
		foreach ($this->device->interfaces AS $interface) {
			if (!$interface->ignore) {
				$opts[] = 'DEF:outoctets_'.$interface->id.'='.$interface->getRrdPath().':OUTOCTETS:AVERAGE';
				$outoctets[] = 'outoctets_'.$interface->id.',UN,0,outoctets_'.$interface->id.',IF'; 			
				$opts[] = 'DEF:inoctets_'.$interface->id.'='.$interface->getRrdPath().':INOCTETS:AVERAGE';
				$inoctets[] = 'inoctets_'.$interface->id.',UN,0,inoctets_'.$interface->id.',IF'; 			
				$pluses[] = '+';
			}
		}
		if (isset($pluses[0])) unset($pluses[0]);
		$opts[] = '-v';
		$opts[] = 'bit/s';
		$opts[] = 'CDEF:inoctets='.implode(',',$inoctets).','.implode(',',$pluses);
		$opts[] = 'CDEF:outoctets='.implode(',',$outoctets).','.implode(',',$pluses);
		$opts[] = 'CDEF:doutoctets=outoctets,-1,*';
		$opts[] = 'CDEF:inbits=inoctets,8,*';
		$opts[] = 'CDEF:outbits=outoctets,8,*';
		$opts[] = 'CDEF:doutbits=doutoctets,8,*';
		$opts[] = 'VDEF:totin=inoctets,TOTAL';
		$opts[] = 'VDEF:totout=outoctets,TOTAL';
		$opts[] = 'AREA:doutbits#C3D9FF:';
		$opts[] = 'LINE1.25:doutbits#000099:Out';
		$opts[] = 'GPRINT:outbits:LAST:%6.2lf%s';
		$opts[] = 'GPRINT:outbits:AVERAGE:%6.2lf%s';
		$opts[] = 'GPRINT:outbits:MAX:%6.2lf%s';
		$opts[] = 'GPRINT:totout:%6.2lf%s\n';
		$opts[] = 'AREA:inbits#CDEB8B:';
		$opts[] = 'LINE1.25:inbits#006600:In';
		$opts[] = 'GPRINT:inbits:LAST: %6.2lf%s';
		$opts[] = 'GPRINT:inbits:AVERAGE:%6.2lf%s';
		$opts[] = 'GPRINT:inbits:MAX:%6.2lf%s';
		$opts[] = 'GPRINT:totin:%6.2lf%s\n';
		$opts[] = 'COMMENT:BPS      Now       Ave      Max      Total\n';
		return $opts;
	}
}